Popular Searches
Popular Course Categories
Popular Courses

Installing and Configuring IntelliJ IDEA, Eclipse, or VS Code

Installing and Configuring IntelliJ IDEA, Eclipse, or VS Code

Java Installation and Development Environment Setup

Installing and Configuring IntelliJ IDEA, Eclipse, or VS Code

Course: Core Java Training

Topic: Installing and Configuring IntelliJ IDEA, Eclipse, or VS Code

Course Link: Core Java Training Course

Demo Link: Register for a Course Demo


1. Introduction to Java Development Environments

A Java development environment provides the tools required to write, compile, execute, test, and debug Java programs. Developers can use a command-line terminal, a full-featured Integrated Development Environment (IDE), or a code editor equipped with Java extensions.

IntelliJ IDEA, Eclipse IDE, and Visual Studio Code (VS Code) are widely used tools for Java development. IntelliJ IDEA and Eclipse provide comprehensive IDE features, while VS Code is a flexible code editor that gains Java development capabilities through extensions.

Choosing and configuring an appropriate environment is an important first step in learning Core Java. A properly configured environment helps developers identify errors, manage projects, execute programs, and organize source code efficiently.

2. Learning Objectives

  • Understand the role of an IDE in Java development.
  • Understand the differences between the JDK, JVM, and IDE.
  • Compare IntelliJ IDEA, Eclipse, and VS Code.
  • Download and install a suitable Java Development Kit.
  • Install and configure each development environment.
  • Create Java projects and source files.
  • Compile, execute, and debug Java programs.
  • Troubleshoot common installation and configuration problems.

3. Understanding the JDK, JVM, and IDE

3.1 Java Development Kit (JDK)

The Java Development Kit is a collection of tools used to develop Java applications. It includes the Java compiler, application launcher, and other development utilities, along with the runtime components required to run Java programs.

The two important commands used to verify a Java installation are:

java -version
javac -version

The java command displays information about the selected Java runtime, while javac displays the compiler version. A suitable JDK is necessary for compiling Java source code.

3.2 Java Virtual Machine (JVM)

The Java Virtual Machine executes Java bytecode. It loads classes, manages memory, and provides runtime services. Compatible JVM implementations allow Java applications to run on different operating systems.

3.3 Integrated Development Environment (IDE)

An IDE combines several development tools in a single application. It generally provides a source-code editor, project explorer, code completion, compiler integration, run configurations, debugging tools, and error reporting.

3.4 How These Components Work Together

  1. The developer writes Java source code in a .java file.
  2. The JDK compiler translates the source code into bytecode when compilation is required.
  3. The Java runtime loads and executes the compiled classes.
  4. The IDE helps the developer manage these operations through a graphical interface.

4. Comparing IntelliJ IDEA, Eclipse, and VS Code

Feature IntelliJ IDEA Eclipse IDE VS Code
Type Full-featured IDE Full-featured IDE Extensible code editor
Java support Built-in Java development capabilities Strong Java development support Available through Java extensions
Code completion Advanced completion and navigation Completion and navigation tools Provided by language extensions
Debugging Integrated debugger Integrated debugger Java debugging through extensions
Project management Java, Maven, and Gradle projects Java and build-tool projects Folder-based and Java project workflows
Customization Plugins and IDE settings Plugins and preferences Extensions and editor settings
Best suited for Beginners and professional developers Learning and enterprise development Developers who prefer a flexible editor

Each environment can be used to learn Core Java. Beginners should select one tool, configure it correctly, and focus on Java fundamentals before spending time learning multiple IDEs.

5. Preparing the Computer for Java Development

Step 1: Select a JDK Version

Choose a JDK version supported by your IDE and compatible with your course or project requirements. A supported long-term support (LTS) release is often a practical choice for a new project, but the required Java version should always take priority.

Step 2: Download a JDK

Use an official or trusted JDK distribution. The following resources provide Java downloads:

Step 3: Install the JDK

Download the installer or archive appropriate for your operating system. Follow the installation instructions and note the installation directory because the IDE may need that path when configuring the project SDK.

Step 4: Verify Java Installation

Open a new terminal window and execute:

java -version
javac -version

If both commands display version information, the Java launcher and compiler are available through the terminal. If the commands are not recognized, verify the installation and PATH configuration.

6. Configuring JAVA_HOME and PATH

The JAVA_HOME environment variable identifies the JDK installation directory. The PATH variable allows the operating system to locate commands such as java and javac without requiring their full executable paths.

6.1 Example JAVA_HOME Locations

Windows: C:\Program Files\Java\jdk-XX
macOS:   /Library/Java/JavaVirtualMachines/jdk-XX.jdk/Contents/Home
Linux:   /usr/lib/jvm/jdk-XX

These are examples only. Replace the placeholder paths with the actual installation directory on your computer. The JAVA_HOME value should point to the JDK root directory rather than its bin subdirectory.

6.2 Configuring PATH

Add the JDK's bin directory to PATH if you want to run Java commands from a terminal. On Windows, use the Environment Variables settings. On macOS and Linux, the process depends on the shell and system configuration.

Preserve existing PATH entries when making changes. After updating environment variables, open a new terminal and verify the commands again.

6.3 Checking the Active Java Installation

# Windows
where java
where javac

# macOS or Linux
which java
which javac

These commands help identify the executable paths used by the terminal. An IDE can use a different JDK from the one selected by the terminal, so check the IDE's project configuration separately.

7. Installing and Configuring IntelliJ IDEA

IntelliJ IDEA is a Java development environment with code completion, navigation, refactoring, project management, and integrated execution and debugging features.

7.1 Download IntelliJ IDEA

  1. Open the official IntelliJ IDEA download page.
  2. Select the version and installer appropriate for your operating system.
  3. Review the available edition and licensing information.
  4. Download the installer from the official website.

7.2 Install IntelliJ IDEA

  1. Run the downloaded installer.
  2. Follow the installation wizard.
  3. Choose the installation options suitable for your computer.
  4. Complete the installation and launch IntelliJ IDEA.
  5. Review the initial setup screens and configure your preferred settings.

Installation screens and available options may vary by operating system and product version.

7.3 Create a Java Project

  1. Open IntelliJ IDEA.
  2. Select the option to create a new project.
  3. Choose Java as the project language or project type.
  4. Select an installed JDK or configure a JDK location if prompted.
  5. Enter a project name such as CoreJavaPractice.
  6. Choose a project location and create the project.

7.4 Create a Java Class

Inside the project's source directory, create a Java class named HelloWorld and enter the following code:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello from IntelliJ IDEA!");
    }
}

7.5 Run the Program

  1. Save the Java file.
  2. Click the run icon near the main method or use the Run menu.
  3. Review the output in the Run tool window.
  4. If an error appears, check the JDK and project configuration.

Expected output:

Hello from IntelliJ IDEA!

7.6 Configure the Project SDK

The Project SDK identifies the JDK used by the project. If the IDE reports an invalid SDK or the program uses an unexpected Java version, open the project structure or SDK settings and check the selected JDK and language level.

7.7 Useful IntelliJ IDEA Features

  • Code completion and syntax highlighting.
  • Navigation to class declarations and usages.
  • Code inspections and automated refactoring.
  • Run and debug configurations.
  • Maven and Gradle project support.
  • Plugins for additional development capabilities.

8. Installing and Configuring Eclipse IDE

Eclipse IDE is a widely used development environment that provides Java editing, compilation, project management, debugging, and plugin support. The Eclipse IDE package for Java developers is a convenient starting point for Core Java learners.

8.1 Download Eclipse

  1. Visit the official Eclipse Packages page.
  2. Choose a package suitable for Java development and your operating system.
  3. Download the installer or package from the official Eclipse website.

8.2 Install Eclipse

  1. Launch the Eclipse Installer if you downloaded it.
  2. Select the Java development package.
  3. Choose an installation directory.
  4. Complete the installation and launch Eclipse.
  5. Choose a workspace directory when prompted.
  6. Confirm the workspace to open the Eclipse workbench.

A workspace stores Eclipse workspace information, project references, and related settings. You can use separate workspaces to organize different sets of projects.

8.3 Configure the JDK

  1. Open Eclipse.
  2. Open the installed Java runtime settings. On many Windows and Linux installations, these are available through Window > Preferences > Java > Installed JREs.
  3. On macOS, open the corresponding preferences through the Eclipse application menu.
  4. Check whether the desired JDK is listed.
  5. If it is missing, add the actual JDK installation directory.
  6. Select the appropriate runtime for your workspace where required.

Menu names may vary by Eclipse version. The runtime used to launch Eclipse and the JDK used by a project can be configured separately.

8.4 Create a Java Project

  1. Select File > New > Java Project.
  2. Enter a project name such as CoreJavaPractice.
  3. Select the required JDK or execution environment.
  4. Review the project source folder and layout.
  5. Finish the wizard.

8.5 Create a Java Class

  1. Expand the project in Package Explorer.
  2. Right-click the source folder, usually named src.
  3. Select New > Class.
  4. Enter HelloWorld as the class name.
  5. Select the option to generate a main method if available.
  6. Finish the wizard.

Enter the following code:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello from Eclipse!");
    }
}

8.6 Run the Program

  1. Save the source file.
  2. Right-click the class in Package Explorer or in the editor.
  3. Select Run As > Java Application.
  4. View the output in the Console panel.

Expected output:

Hello from Eclipse!

8.7 Configure the Compiler Version

Open the project properties and locate the Java Compiler settings. Choose a compiler compliance level that supports the language features used by your code and is compatible with the project requirements.

8.8 Useful Eclipse Features

  • Package Explorer for navigating project files.
  • Java editor with syntax highlighting and code completion.
  • Quick fixes and refactoring tools.
  • Integrated console and debugger.
  • Support for Maven and Gradle through available tooling.
  • Additional plugins through the Eclipse Marketplace.

9. Installing and Configuring Visual Studio Code

Visual Studio Code is a flexible code editor that supports Java development through extensions. It is useful for learners who want a lightweight editor that can also be used for other programming languages.

9.1 Download VS Code

  1. Open the official Visual Studio Code download page.
  2. Select the installer or package for your operating system and processor.
  3. Download and install the application.
  4. Launch VS Code.

9.2 Install and Verify a JDK

Install a JDK compatible with your Java project and the Java extensions. Open a terminal and check:

java -version
javac -version

If the commands are unavailable, verify the JDK installation and environment variables before configuring the editor.

9.3 Install the Extension Pack for Java

  1. Open VS Code.
  2. Open the Extensions view from the sidebar.
  3. Search for Extension Pack for Java.
  4. Verify the publisher and extension details.
  5. Install the extension pack.
  6. Wait for the extensions to initialize and reload the editor if requested.

The extension pack provides Java language support and tools for editing, running, debugging, and managing Java projects. Its included extensions may change as the product evolves.

Official guide: Java Development in VS Code.

9.4 Open a Project Folder

  1. Create a folder named CoreJavaPractice.
  2. Open VS Code.
  3. Select File > Open Folder.
  4. Choose the project folder.
  5. Follow workspace trust prompts carefully, especially when opening code from an unfamiliar source.

9.5 Create a Java File

Create a file named HelloWorld.java in the opened folder and enter the following code:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello from VS Code!");
    }
}

9.6 Run the Program

  1. Save the source file.
  2. Wait for Java language support to initialize.
  3. Use the Run option displayed above the main method if available.
  4. Alternatively, open the integrated terminal and execute the commands below.
javac HelloWorld.java
java HelloWorld

Expected output:

Hello from VS Code!

9.7 Configure the Java Runtime

If VS Code detects multiple JDKs or selects an unsuitable runtime, use the Java extension's runtime configuration options to review the installed JDKs and project settings.

For further information, see VS Code Java Project Management.

9.8 Useful VS Code Features

  • Java syntax highlighting and code completion.
  • Run and debug commands for Java programs.
  • Integrated terminal for Java commands.
  • Source navigation and refactoring tools.
  • Java testing and project tools through extensions.
  • Additional extensions for Git, databases, and other languages.

10. Understanding Java Project Structure

A consistent project structure makes code easier to understand, maintain, and share. A simple practice project may use the following layout:

CoreJavaPractice/
├── src/
│   └── HelloWorld.java
└── README.md

A project using packages can be organized like this:

CoreJavaPractice/
├── src/
│   └── com/
│       └── example/
│           └── HelloWorld.java
├── out/
└── README.md

When a class declares package com.example;, its source file should be organized under the matching package directory inside the source root. IDEs usually manage package directories when you create classes through their project tools.

11. Configuring Code Formatting and Editor Preferences

Consistent formatting improves readability and makes code easier to review. IntelliJ IDEA, Eclipse, and VS Code offer formatting settings or extensions for managing code style.

  • Indentation: Use a consistent indentation style for code blocks.
  • Formatting: Use the IDE's formatter to standardize spacing and braces.
  • Font size: Select a comfortable editor font size.
  • Syntax highlighting: Keep Java syntax highlighting enabled.
  • Code completion: Use suggestions to improve development speed, but understand the code being inserted.
  • Warnings: Review compiler warnings and code inspections.
  • Save settings: Configure autosave and automatic formatting according to your workflow.

For team projects, use an agreed style guide or shared formatter configuration so that code remains consistent across different development environments.

12. Running and Debugging Java Programs

Running a program checks its behavior, while debugging helps you inspect the program's state and locate errors. All three environments provide ways to run Java applications and debug supported projects.

12.1 Understanding Run Configurations

A run configuration defines how an application starts. Depending on the IDE, it may include the main class, JDK, working directory, program arguments, environment variables, and classpath.

12.2 Setting a Breakpoint

  1. Open a Java source file.
  2. Click beside a line number to set a breakpoint.
  3. Start the application in Debug mode.
  4. When execution pauses, inspect variables and the call stack.
  5. Use step-over, step-into, and resume controls to continue execution.

12.3 Debugging Example

public class DebugExample {
    public static void main(String[] args) {
        int first = 10;
        int second = 5;
        int total = first + second;

        System.out.println("Total: " + total);
    }
}

Set a breakpoint on the calculation of total. Run the program in Debug mode and inspect the values of first, second, and total.

13. Common Installation and Configuration Problems

Problem Possible Cause Solution
Java is not recognized in the terminal. The JDK is missing or PATH is configured incorrectly. Verify the installation and configure PATH if needed.
The IDE cannot find a JDK. The JDK is not registered in the IDE. Select the actual JDK installation directory in the IDE settings.
Compilation fails because of language features. The configured compiler level is too old. Check the required Java version and compiler settings.
The program runs with an unexpected Java version. The terminal and IDE use different JDK installations. Check the terminal executable path and project SDK.
The Run option is unavailable. The file or project is not recognized as a Java application. Check the source filename, main method, project setup, and Java support.
VS Code does not provide Java features. Java extensions are missing, disabled, or still initializing. Install or enable the Java extension pack and wait for initialization.
Eclipse displays errors for a simple class. The JDK, build path, or compiler compliance settings may be incorrect. Review installed runtimes, Java Build Path, and compiler settings.
IntelliJ IDEA reports an invalid SDK. The configured JDK directory is invalid or no longer exists. Select a valid JDK in the project SDK settings.
The IDE runs slowly. System resource limits, large projects, or excessive extensions may affect performance. Close unnecessary projects and review resource use and installed extensions.
A dependency cannot be resolved. The dependency or build-tool configuration is incomplete. Check the dependency declaration and refresh the Maven or Gradle project.

14. Best Practices for Java Environment Setup

  • Download Java tools and extensions from official or trusted sources.
  • Choose a JDK compatible with the project's Java version.
  • Verify both the terminal Java version and the IDE's configured JDK.
  • Use clear project names and organized source directories.
  • Learn basic terminal commands even when the IDE automates compilation.
  • Understand the difference between the IDE runtime, project SDK, and compiler language level.
  • Install only necessary extensions and plugins.
  • Use version control for projects that will grow beyond small exercises.
  • Use Maven or Gradle when a project needs repeatable builds and dependency management.
  • Read the complete error message before changing environment settings.

15. Practical Exercises

Exercise 1: Install and Verify the JDK

Install a suitable JDK, run java -version and javac -version, and record the versions displayed in the terminal.

Exercise 2: Set Up IntelliJ IDEA

Create a Java project named JavaBasics, add a HelloWorld class, and run it. Confirm that the expected output appears in the Run window.

Exercise 3: Set Up Eclipse

Create a project named EclipsePractice, configure the JDK, create a class, and run it using Run As > Java Application.

Exercise 4: Set Up VS Code

Install the Java extension pack, open a project folder, create a Java source file, and run it through the Run action or integrated terminal.

Exercise 5: Compare the Three Environments

Run the same Java program in all three tools. Compare the editing experience, error messages, project organization, and debugging workflow.

Exercise 6: Create a Java Package

Create a class in the com.practice package and run it in your chosen IDE. If comfortable, compile and execute it using the terminal as well.

Exercise 7: Debug a Program

Create a program that adds two numbers. Set a breakpoint, inspect the variables, and step through the calculation.

16. Core Java Interview Questions and Answers

Q1. What is an IDE?

Answer: An Integrated Development Environment combines tools for writing, organizing, running, testing, and debugging code.

Q2. What is the difference between a JDK and an IDE?

Answer: The JDK provides Java development tools and runtime components. An IDE provides an interface and workflow for using development tools and managing projects.

Q3. Can Java programs be developed in VS Code?

Answer: Yes. Install a compatible JDK and Java extensions to enable Java editing, project management, execution, and debugging.

Q4. What is a workspace in Eclipse?

Answer: A workspace stores Eclipse workspace information, project references, and related settings.

Q5. What is a Project SDK in IntelliJ IDEA?

Answer: It identifies the JDK used by the project for development and compilation-related tasks according to the project configuration.

Q6. Why might an IDE fail to recognize Java?

Answer: The JDK may be missing, the IDE may not have a valid JDK configured, or the project may reference a different installation.

Q7. What is a breakpoint?

Answer: A breakpoint pauses execution at a selected line so developers can inspect variables, the call stack, and program behavior.

Q8. What is the difference between running and debugging?

Answer: Running executes the application normally. Debugging allows developers to pause execution and inspect internal program state.

Q9. Why is a consistent Java version important?

Answer: The compiler, source code, dependencies, and runtime must use compatible versions to avoid unsupported language features and bytecode compatibility problems.

Q10. Do beginners need all three tools?

Answer: No. One correctly configured development environment is sufficient for learning Core Java. Other tools can be explored later.

17. Quick Revision Checklist

  • Understand the difference between the JDK, JVM, and IDE.
  • Install a suitable JDK from a trusted source.
  • Verify Java and compiler versions in the terminal.
  • Install IntelliJ IDEA, Eclipse, or VS Code.
  • Configure the JDK for the selected environment.
  • Create a Java project and a class containing a main method.
  • Run the program and verify the expected output.
  • Understand source folders, package directories, and project settings.
  • Practice setting breakpoints and debugging code.
  • Learn to troubleshoot common JDK, classpath, and extension issues.

18. Official Documentation and Downloads

19. Learn Core Java with JustAcademy

Continue learning Java fundamentals, object-oriented programming, classes and objects, exception handling, collections, and practical application development through the JustAcademy Core Java Training Course.

You can register for a course demo to learn more about the training.

Visit the JustAcademy homepage to explore additional courses and learning resources.

20. Conclusion

Installing and configuring a Java development environment is an essential first step in Core Java programming. IntelliJ IDEA and Eclipse provide full-featured IDE workflows, while VS Code offers a flexible editor with Java capabilities enabled through extensions. All three can support learning and application development when configured with a compatible JDK.

After setting up one environment, practice creating projects, writing classes, running programs, and debugging errors. A reliable development setup makes it easier to progress to advanced Java concepts and real-world projects.

whatsapp